﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace WishHand.Core
{
    public class CsvHelper
    {
        public static List<List<string>> ReadCsv(string csvName, Encoding encoding, int headerCount = 0,
    char colSplit = ',')
        {
            List<List<string>> list = new List<List<string>>();
            string[] strArray = File.ReadAllLines(csvName, encoding);
            int index = headerCount;
            while (index < strArray.Length)
            {
                string str = strArray[index];
                List<string> item = new List<string>();
                string[] strArray2 = str.Split(new char[] { colSplit });
                for (int i = 0; i < strArray2.Length; i++)
                {
                    item.Add(strArray2[i].Replace("\"", "").Replace("'", "").Replace("||", "").Replace("|", ""));
                }

                list.Add(item);
                index++;
            }

            return list;
        }
    }
}
